package com.rxt.controller;


import com.rxt.common.result.Result;
import com.rxt.model.vo.QQuestionVo;
import com.rxt.service.IQQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 周梓文
 * @since 2023-08-24
 */
@Slf4j
@Api(tags = "提问模块")
@RestController
@RequestMapping("/qQuestion")
public class QQuestionController {

    @Autowired
    private IQQuestionService iqQuestionService;

    @PostMapping("/publish")
    @ApiOperation("添加问题")
    public Result publish(@RequestBody QQuestionVo qQuestionVO){
        log.info("{}", qQuestionVO);
        return iqQuestionService.publish(qQuestionVO);
    }

    @ApiOperation("根据专家id查询问题")
    @GetMapping("/expert/{id}")
    public Result getByExpertId(@PathVariable Long id){
        return iqQuestionService.getByExpertId(id);
    }

    @ApiOperation("获取热门问答")
    @GetMapping("/hot")
    public Result hot(){
        return iqQuestionService.hot();
    }

    @ApiOperation("查询个人的提问")
    @GetMapping("/user")
    public Result getByUserId(){
        return iqQuestionService.getUsers();
    }

    @ApiOperation("删除指定问答")
    @DeleteMapping("/{id}")
    public Result getByUserId(@PathVariable Long id){
        return iqQuestionService.deleteById(id);
    }


}

